package com.flyme.module.base.provider.api;

import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil;
import cn.hutool.json.JSONUtil;
import com.flyme.common.core.aliyun.sms.AliSmsUtil;
import com.flyme.common.core.aliyun.sms.SmsTempEnum;
import com.flyme.common.core.model.ResultBody;
import com.flyme.common.core.security.OpenHelper;
import com.flyme.common.core.security.OpenUserAuth;
import com.flyme.common.core.utils.ApiAssert;
import com.flyme.common.core.utils.ObjectUtils;
import com.flyme.core.base.supper.controller.BaseController;
import com.flyme.core.base.supper.entity.EntityMap;
import com.flyme.module.base.client.entity.*;
import com.flyme.module.base.client.enums.*;
import com.flyme.module.base.provider.service.*;
import com.flyme.module.exam.client.entity.*;
import com.flyme.module.exam.client.enums.AbilityItemEnum;
import com.flyme.module.exam.client.enums.LevelTypeEnum;
import com.flyme.module.exam.client.enums.duanTypeEnum;
import com.flyme.module.exam.client.vo.ExamVO;
import com.flyme.module.exam.provider.service.*;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.apache.xmlbeans.impl.xb.xsdschema.Public;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;


/**
 * @author flyme
 */
@Slf4j
@Api(tags = "app订单管理")
@RestController
@RequestMapping("/ability")
public class ApiAbilityController extends BaseController<BusAbiltityService, BusAbility> {

    @Autowired
    private BusAbiltityService abilityService;
    @Autowired
    private SysEducationService educationService;
    @Autowired
    private SysVipService vipaccountService;
    @Autowired
    private SysBuyrecordService sysbuyrecordService;
    @Autowired
    private SysConfigService sysconfigService;
    @Autowired
    private ExamRecordService examRecordService;
    @Autowired
    private SysBuyrecordService buyrecordService;
    @Autowired
    private ExamTypeService abilityitemService;
    @Autowired
    private BusUserabilityService userabilityService;
    @Autowired
    private SysWorkCourseService workcourseService;
    @Autowired
    private SysCompanyEvaService companyevaService;
    @Autowired
    private ExaDuanService duanService;
    @Autowired
    private ExamService examService;
    @Autowired
    private ExamRecordService answerrecordService;
    @Autowired
    private ExamRecordDetailsService answerdetailService;
    @Autowired
    private SysVipService vipService;
    @Autowired
    private ExamOptService examoptService;
    /**
     * 人才能力测评页面
     * isBuy 1已购买2为购买
     */
    @PostMapping(value = "/abilityPage")
    public ResultBody abilityPage() {
        OpenUserAuth openUserAuth = OpenHelper.getUserAuth();
        EntityMap map = new EntityMap();
        BusAbility ability = abilityService.list().get(0);
        Integer educationNum = educationService.countByUserId(openUserAuth.getUserId());
        map.put("education", educationNum);
        map.put("ability", ability);
        Integer vip = vipService.isVip(openUserAuth.getUserId());
        if(vip>0){
            map.put("isBuy", 1);
        }else{
            //查询用户是否购买过能力测评
            Integer record = sysbuyrecordService.findByUser(openUserAuth.getUserId());
            map.put("isBuy", record);
        }
        /*String userId = String.valueOf(openUserAuth.getUserId());
        JpushPush jPush = new JpushPush();
        Map<String, String> msg = new HashMap<String, String>();
        List<String> aliases = new ArrayList<>();
        aliases.add(userId);
        String pushMsg = "您的订单已支付成功，请在订单详情中查看";
        //发送推送
        msg.put("msg", pushMsg);
        msg.put("pushType", "1");
        msg.put("content", pushMsg);
        msg.put("orderId", "1108417669807079425");
        jPush.pushByAlias("COMM", aliases, pushMsg, "2", userId, msg);*/
        return ResultBody.success(map);
    }

    /**
     * 我的能力页面
     */
    @PostMapping(value = "/userAbility")
    public ResultBody userAbility(){
        OpenUserAuth openUserAuth = OpenHelper.getUserAuth();
        EntityMap map = new EntityMap();
        String workId = String.valueOf(abilityitemService.findByCode(AbilityItemEnum.work.code).getId());
        String educationId = String.valueOf(abilityitemService.findByCode(AbilityItemEnum.education.code).getId());
        String synthesisId = String.valueOf(abilityitemService.findByCode(AbilityItemEnum.synthesis.code).getId());
        Long userId = openUserAuth.getUserId();
        BigDecimal all = new BigDecimal("0");
        //能力测评总分
        Map<String, Object> myAbility = userabilityService.countOther(userId, workId, educationId, synthesisId);
        //学历分
        BigDecimal studyScore = new BigDecimal(userabilityService.countUser(userId, educationId));
        //工作分
        BigDecimal workScore = new BigDecimal(userabilityService.countUser(userId, workId));
        //hr评分
        Map<String, Object> hrScore = userabilityService.countUserHr(userId);
        BigDecimal abilityScore = new BigDecimal(myAbility.get("score").toString());//能力测评总分
        String gethr = hrScore.get("score").toString();
        if(ObjectUtils.isNotEmpty(hrScore) &&  !gethr.equals("0.0") ){//hr评分不为空且不等于0时，测评分乘以0.7+hr+学历+工作
            BigDecimal hr = new BigDecimal(hrScore.get("score").toString()).multiply(new BigDecimal("0.3"));
            all = studyScore.add(workScore).add(hr).add(abilityScore.multiply(new BigDecimal("0.7")));
        }else{//测评分+工作+学历
            all = studyScore.add(workScore).add(abilityScore);
        }
        //测评得分（上一次测评得分）
        ExamRecord answerrecord = examRecordService.findByUser(userId);
        if(ObjectUtils.isEmpty(answerrecord)){
            answerrecord = new ExamRecord();
        }
        Integer testNum = examRecordService.countByUser(userId);
        answerrecord.setTestNum(testNum);
        map.put("isBuy", 2);
        SysVipType vip = vipaccountService.getUserVip(openUserAuth.getUserId());
        if(ObjectUtils.isNotEmpty(vip)){
            map.put("isBuy", 1);
        }
        //查询用户是否购买过能力测评
        Integer record = buyrecordService.findByUser(userId);
        if(record>0){
            map.put("isBuy", 1);
        }
        SysEducation education = educationService.findByUserId(openUserAuth.getUserId());
        map.put("education", 1);
        if(ObjectUtils.isEmpty(education)){//用户没有教育记录
            map.put("education", 2);
        }
        map.put("myAbility", all);
        map.put("myAbilityAll", "800");
        map.put("studyScore", studyScore);
        map.put("studyScoreAll", sysconfigService.getByName("EDUCATION").getConfigVal());
        map.put("workScore", workScore);
        map.put("workScoreAll", sysconfigService.getByName("WORK").getConfigVal());
        map.put("answerrecord", answerrecord);
        BusAbility ability = abilityService.list().get(0);
        map.put("abilityId", ability.getId());
        map.put("tu", "http://api.cbstudy.com/base/common/line?userId="+userId);
        Integer dateNum = examRecordService.countByMonth(userId);
        map.put("date", dateNum);
        Integer weekNum = examRecordService.countByWeek(userId, DateUtil.beginOfWeek(DateUtil.date()), DateUtil.endOfWeek(DateUtil.date()));
        map.put("testWeekNum", weekNum);
        return ResultBody.success(map);
    }




    /**
     * 我的学历分页面
     */
    @PostMapping(value = "/myEducationPage")
    public ResultBody myEducationPage(){
        EntityMap map = new EntityMap();
        OpenUserAuth openUserAuth = OpenHelper.getUserAuth();
        Long userId = openUserAuth.getUserId();
        String educationId = String.valueOf(abilityitemService.findByCode(AbilityItemEnum.education.code).getId());
        String studyScore = userabilityService.countUser(userId, educationId);//学历分
        SysEducation education = educationService.findByUserId(openUserAuth.getUserId());
        if(ObjectUtils.isEmpty(education)){
            education = new SysEducation();
        }
        education.setEducation(EducationEnum.getText(education.getEducation()));
        education.setMajor(ProfessionEnum.getText(education.getMajor()));
        education.setGrade(RankEnum.getText(education.getGrade()));
        map.put("education", education);
        map.put("studyScore", studyScore);//教育分
        map.put("studyScoreAll", sysconfigService.getByName("EDUCATION").getConfigVal());
        return ResultBody.success(map);
    }


    /**
     * 我的工作分页面
     */
    @PostMapping(value = "/myWorkPage")
    public ResultBody myWorkPage(){
        EntityMap map = new EntityMap();
        OpenUserAuth openUserAuth = OpenHelper.getUserAuth();
        Long userId = openUserAuth.getUserId();
        String workId = String.valueOf(abilityitemService.findByCode(AbilityItemEnum.work.code).getId());
        String workScore = userabilityService.countUser(userId, workId);//学历分
        List<SysWorkCourse> works = workcourseService.selectByUserId(openUserAuth.getUserId());
        for(SysWorkCourse work : works){
            work.setOperationType(CommercialEnum.getText(work.getOperationType()));
            work.setPosition(PostEnum.getText(work.getPosition()));
        }
        map.put("works", works);
        map.put("workScore", workScore);//工作分
        map.put("workScoreAll", sysconfigService.getByName("WORK").getConfigVal());
        return ResultBody.success(map);
    }

    /**
     * 雷达图页面（主）
     */
    @PostMapping(value = "/radarPage")
    public ResultBody radarPage(){
        EntityMap map = new EntityMap();
        OpenUserAuth openUserAuth = OpenHelper.getUserAuth();
        Long userId = openUserAuth.getUserId();
        List<String> items = new ArrayList();
        items.add(AbilityItemEnum.education.code);
        items.add(AbilityItemEnum.work.code);
        items.add(AbilityItemEnum.synthesis.code);
        List<EntityMap> abilityList = abilityitemService.selectFound(userId, items);
        List<SysCompanyEva> evaList = companyevaService.selectByUser(userId);
        map.put("evaList", evaList);
        map.put("abilityList", abilityList);
        String educationId = String.valueOf(abilityitemService.findByCode(AbilityItemEnum.education.code).getId());
        String studyScore = userabilityService.countUser(userId, educationId);//学历分
        SysEducation education = educationService.findByUserId(openUserAuth.getUserId());
        map.put("education", new SysEducation());
        if(ObjectUtils.isNotEmpty(education)){
            education.setEducation(EducationEnum.getText(education.getEducation()));
            education.setMajor(ProfessionEnum.getText(education.getMajor()));
            education.setGrade(RankEnum.getText(education.getGrade()));
            map.put("education", education);
        }
        map.put("studyScore", studyScore);//教育分
        String workId = String.valueOf(abilityitemService.findByCode(AbilityItemEnum.work.code).getId());
        String workScore = userabilityService.countUser(userId, workId);//学历分
        List<SysWorkCourse> works = workcourseService.selectByUserId(openUserAuth.getUserId());
        if(ObjectUtils.isNotEmpty(works)){
            for(SysWorkCourse work : works){
                work.setOperationType(CommercialEnum.getText(work.getOperationType()));
                work.setPosition(PostEnum.getText(work.getPosition()));
                work.setWorkingLife(work.getWorkingLife());
            }
        }else{
            works = new ArrayList();
        }
        map.put("works", works);
        map.put("workScore", workScore);//工作分
        return ResultBody.success(map);
    }

    /**
     * 雷达图页面（副）
     */
    @PostMapping(value = "/radarPage2")
    public ResultBody radarPage2(){
        EntityMap map = new EntityMap();
        List<ExamType> list = abilityitemService.selectAll();
        List<EntityMap> abilityList = new ArrayList<>();
        OpenUserAuth openUserAuth = OpenHelper.getUserAuth();
        String userId = String.valueOf(openUserAuth.getUserId());
        for(ExamType abilityitem : list){
            if(abilityitem.getExamTypeCode().equals(AbilityItemEnum.education.code)
                    || abilityitem.getExamTypeCode().equals(AbilityItemEnum.work.code)){
                continue;
            }
            EntityMap data = new EntityMap();
            BusUserability userability = userabilityService.findUser(openUserAuth.getUserId(), abilityitem.getId());
            ExaDuan duan = duanService.getById(userability.getDuanId());
            data.put("abilityitemId", abilityitem.getId());
            data.put("abilityitem", abilityitem.getExamTypeName());
            data.put("abilityitemCode", abilityitem.getExamTypeCode());
            data.put("duanName", duan.getDuanName());
            String duanName = duan.getDuanName();
            data.put("gradeName", duan.getDuanName().substring(duanName.length()-2));
            data.put("duanIcon", duan.getDuanIcon());
            data.put("score", userability.getAbilityScore());
            BigDecimal rait = new BigDecimal("0.01");
            if(duan.getDuanLevel().equals("bronze")){
                rait = new BigDecimal(userability.getAbilityScore()).multiply(new BigDecimal("0.04"));
            }
            if(duan.getDuanLevel().equals("silver")){
                rait = new BigDecimal(userability.getAbilityScore()).multiply(new BigDecimal("0.0267"));
            }
            if(duan.getDuanLevel().equals("gold")){
                rait = new BigDecimal(userability.getAbilityScore()).multiply(new BigDecimal("0.01875"));
            }
            if(duan.getDuanLevel().equals("platinum")){
                rait = new BigDecimal(userability.getAbilityScore()).multiply(new BigDecimal("0.01333"));
            }
            if(duan.getDuanLevel().equals("diamond")){
                rait = new BigDecimal(userability.getAbilityScore()).multiply(new BigDecimal("0.01"));
            }
            data.put("rait", rait);
            abilityList.add(data);
        }
        map.put("abilityList", abilityList);//能力列表
        return ResultBody.success(map);
    }

    /**
     * 开始测评获取题目
     */
    @PostMapping(value = "/getSubject")
    public ResultBody getSubject(Long abilityitemId){
        OpenUserAuth openUserAuth = OpenHelper.getUserAuth();
        EntityMap map = new EntityMap();
        ExamType abilityitem = abilityitemService.getById(abilityitemId);
        //查询用户当前测评项目等级
        BusUserability userability = userabilityService.findUser(openUserAuth.getUserId(), abilityitemId);
        ExaDuan duan = duanService.getById(userability.getDuanId());
        //根据用户选择项目随机挑选题目
        List<Map<String, Object>> list = new ArrayList<>();
        if(abilityitem.getExamTypeCode().equals(AbilityItemEnum.synthesis.code)){
            List<ExamType> items = abilityitemService.selectOthers();
            for(ExamType item : items){
                List<Map<String, Object>> itemExams = examService.selectByItem2(item, duan, abilityitem.getExamTypeCode(), list.size());
                list.addAll(itemExams);
            }
        }else{
            list = examService.selectByItem2(abilityitem, duan, null,0);
        }
        Map<String, String> params = new HashMap<>();
        Integer num = duan.getDuanName().length();
        String phone = sysconfigService.getByName("tipsPhone").getConfigVal();
        if(abilityitem.getExamTypeCode().equals(AbilityItemEnum.synthesis.code) && list.size() < 30){
            params.put("typel", "综合能力测评");
            params.put("level", duan.getDuanName().substring(0, (num - 2)));
            params.put("rank", duan.getDuanName().substring(num - 2));
            Boolean tag = AliSmsUtil.sendSmsCode(SmsTempEnum.TIPS, phone, params);
            return ResultBody.failed("题库维护中，请稍后再试");
        }
        if(!abilityitem.getExamTypeCode().equals(AbilityItemEnum.synthesis.code) && list.size() < 5){
            params.put("typel", abilityitem.getExamTypeName());
            params.put("level", duan.getDuanName().substring(0, (num - 2)));
            params.put("rank", duan.getDuanName().substring(num - 2));
            Boolean tag = AliSmsUtil.sendSmsCode(SmsTempEnum.TIPS, phone, params);
            return ResultBody.failed("题库维护中，请稍后再试");
        }
        map.put("list", list);
        map.put("duan", duan.getDuanName());
        return ResultBody.success(map);
    }


    /**
     * 提交用户答题接口
     */
    @PostMapping(value = "/subExam")
    public ResultBody subExam(String answer, Long abilityItemId){
        ApiAssert.notNull("参数不能为空", abilityItemId);
        EntityMap map = new EntityMap();
        OpenUserAuth openUserAuth = OpenHelper.getUserAuth();
        Long userId =openUserAuth.getUserId();
        ExamType abilityItem = abilityitemService.getById(abilityItemId);
        //查询用户当前评测项目的等级
        BusUserability userability = userabilityService.findUser(openUserAuth.getUserId(), abilityItemId);
        ExaDuan duan = duanService.getById(userability.getDuanId());
        //生成答题记录
        ExamRecord oldRecord = answerrecordService.findMax(userId, abilityItemId.toString());
        Integer testNum = 1;
        if(ObjectUtils.isNull(oldRecord)){
            oldRecord = new ExamRecord();
            oldRecord.setAccountInfoId(userId);
            oldRecord.setAbilityItem(abilityItem.getExamTypeCode());
            oldRecord.setAbilityItemId(abilityItemId.toString());

        }else{
            testNum = oldRecord.getTestNum()+1;
        }
        oldRecord.setId(null);
        oldRecord.setTestNum(testNum);
        oldRecord.setCreateTime(DateUtil.date());
        Integer trueNum = 0;//答对的题目
        List<ExamVO> answers = JSONUtil.toList(JSONUtil.parseArray(answer) , ExamVO.class);
        for(ExamVO exam : answers){
            if(exam.getIsTrue().equals(1)){
                trueNum = trueNum+1;
            }
        }
        ExaDuan duanMax = duanService.findMax();
        Integer duanNum = duan.getSortOrder();//用户当前等级
        Integer allNum = 30;//总题目数
        if(abilityItem.getExamTypeCode().equals(AbilityItemEnum.synthesis.code)){//选择题目类型为综合
            if(trueNum<11){//答对0~10题，降级
                duanNum = duan.getSortOrder()-1;
                if(duanNum<1){
                    duanNum = 1;
                }
            }
            if(trueNum>20){//答对21题及以上，升级
                duanNum = duan.getSortOrder()+1;
                if(duanNum>duanMax.getSortOrder()){
                    duanNum = duanMax.getSortOrder();
                }
            }
        }else{//选择题目类型不为综合
            allNum = 5;
            if(trueNum<2){//答对0~1题，降级
                duanNum = duan.getSortOrder()-1;
                if(duanNum<1){
                    duanNum = 1;
                }
            }
            if(trueNum>3){//答对4题及以上，升级
                duanNum = duan.getSortOrder()+1;
                if(duanNum>duanMax.getSortOrder()){
                    duanNum = duanMax.getSortOrder();
                }
            }
        }
        //更新用户当前项目测评得分
        ExaDuan nowDuan = duanService.findBySort(duanNum);
        userability.setDuanId(String.valueOf(nowDuan.getId()));
        userability.setAbilityScore(nowDuan.getDuanScore().toString());
        userabilityService.saveOrUpdate(userability);
        oldRecord.setAccuracy(new BigDecimal(trueNum).divide(new BigDecimal(allNum), 2, RoundingMode.HALF_UP).toString());
        oldRecord.setDuanId(String.valueOf(nowDuan.getId()));
        oldRecord.setTestScore(nowDuan.getDuanScore());
        answerrecordService.save(oldRecord);
        for(ExamVO exam : answers){
            Exam exam1 = examService.getById(exam.getExamId());
            //答题记录详情
            ExamRecordDetails answerdetail = new ExamRecordDetails();
            answerdetail.setAccountInfoId(userId);
            answerdetail.setAnswerrecordId(oldRecord.getId().toString());
            answerdetail.setAbilityItem(oldRecord.getAbilityItem());
            answerdetail.setAbilityItemId(oldRecord.getAbilityItemId());
            answerdetail.setExamId(exam.getExamId());
            answerdetail.setExamoptId(exam.getExamoptId());
            answerdetail.setIsTrue(exam.getIsTrue());
            answerdetail.setExamIdStamp(exam1.getExamIdStamp());
            answerdetailService.save(answerdetail);
        }
        changeSubject(answers);
        map.put("duan", nowDuan.getDuanName());
        map.put("duanId", nowDuan.getId());
        return ResultBody.success(map);
    }

    /**
     * 变更题目等级
     */
    private void changeSubject(List<ExamVO> answers){
        BigDecimal upRatio = new BigDecimal(String.valueOf(sysconfigService.getByName("upRatio").getConfigVal()));//题目升级比例
        BigDecimal downRatio = new BigDecimal(String.valueOf(sysconfigService.getByName("downRatio").getConfigVal()));//题目降级比例
        Integer answerTimes = Integer.valueOf(sysconfigService.getByName("answerTimes").getConfigVal());
        List<Exam> list = new ArrayList<>();
        for(ExamVO exam : answers){
            Exam exam1 = examService.getById(exam.getExamId());
            Integer trueNum = answerdetailService.countFrequency(exam1, 1);//该题目当前等级正确次数
            if(exam.getIsTrue().equals(1)){
                ++trueNum;
            }
            Integer frequency = exam1.getFrequency();
            if(ObjectUtils.isEmpty(frequency)){
                frequency = 0;
            }
            ++frequency;//该题目当前等级答题次数
            exam1.setFrequency(frequency);
            //题目答题次数大于等于100
            if(frequency > answerTimes){
                String levelDuan = exam1.getDuanLevel();
                //该题目正确率
                BigDecimal ratio = new BigDecimal(trueNum.toString()).divide(new BigDecimal(frequency.toString()),2,BigDecimal.ROUND_HALF_UP);
                if(ratio.compareTo(upRatio) <= 0){//题目当前正确率小于等于升级比例：小于0.3时升级
                    if(exam1.getLevel().equals(LevelTypeEnum.easy.code)){//当前为简单。升级为中等
                        exam1.setLevel(LevelTypeEnum.medium.code);
                        exam1.setFrequency(0);
                        exam1.setExamIdStamp(exam1.getId().toString() + System.currentTimeMillis());
                    }else if(exam1.getLevel().equals(LevelTypeEnum.medium.code)){//当前为中等。升级为困难
                        exam1.setLevel(LevelTypeEnum.difficulty.code);
                        exam1.setFrequency(0);
                        exam1.setExamIdStamp(exam1.getId().toString() + System.currentTimeMillis());
                    }else if(exam1.getLevel().equals(LevelTypeEnum.difficulty.code)){//当前为困难。升级为更高段位
                        Integer levelNum = duanTypeEnum.getText(levelDuan) + 1;
                        if(levelNum < 6){
                            exam1.setLevel(LevelTypeEnum.easy.code);
                            exam1.setDuanLevel(duanTypeEnum.getByCode(levelNum));
                            exam1.setFrequency(0);
                            exam1.setExamIdStamp(exam1.getId().toString() + System.currentTimeMillis());
                        }
                    }
                }
                if(ratio.compareTo(downRatio) >= 0){//题目当前正确率大于等于降级比例：大于0.8时降级
                    if(exam1.getLevel().equals(LevelTypeEnum.easy.code)){//当前为简单
                        Integer levelNum = duanTypeEnum.getText(levelDuan) - 1;
                        if(levelNum > 0){
                            exam1.setLevel(LevelTypeEnum.difficulty.code);
                            exam1.setDuanLevel(duanTypeEnum.getByCode(levelNum));
                            exam1.setFrequency(0);
                            exam1.setExamIdStamp(exam1.getId().toString() + System.currentTimeMillis());
                        }
                    }else if(exam1.getLevel().equals(LevelTypeEnum.medium.code)){//当前为中等
                        exam1.setLevel(LevelTypeEnum.easy.code);
                        exam1.setFrequency(0);
                        exam1.setExamIdStamp(exam1.getId().toString() + System.currentTimeMillis());
                    }else if(exam1.getLevel().equals(LevelTypeEnum.difficulty.code)){//当前为困难，降级为中等
                        exam1.setLevel(LevelTypeEnum.medium.code);
                        exam1.setFrequency(0);
                        exam1.setExamIdStamp(exam1.getId().toString() + System.currentTimeMillis());
                    }
                }
            }
            list.add(exam1);
        }
        examService.updateBatchById(list);
    }

    public static void main(String[] args) {
        BigDecimal c = new BigDecimal("3").divide(new BigDecimal("10"),2,BigDecimal.ROUND_HALF_UP);
        Integer i = new BigDecimal("0.07").compareTo(new BigDecimal("0.05"));
        System.out.println("21515230521525211" + System.currentTimeMillis());
        System.out.println(c);
    }


}
